package com.apes.framework.plugin.esb.parser.element;

import com.apes.framework.plugin.esb.processor.ChainProcessor;
import com.apes.framework.plugin.esb.processor.jpa.AuthsProcessor;
import com.apes.framework.plugin.filereader.xml.ApesElement;
import org.springframework.stereotype.Component;

/**
 * 功能：权限组解析器
 *
 * @author xul
 * @create 2022-01-06 14:29
 */
@Component
public class AuthsElementParser extends AbstractNestedProcessorParser {

    /**
     * 可解析的元素列表
     **/
    private final String[] elementNames = {"auths"};

    @Override
    <T extends Class> T getChainProcessorClass() {
        return  (T) AuthsProcessor.class;
    }

    @Override
    public String[] getNames() {
        return elementNames;
    }

    @Override
    protected void parseNestedElements(ApesElement element, ChainProcessor processor) {
        element.getNestedElements().stream().forEach(nestedElement -> {
            ((AuthsProcessor) processor).addAuth(nestedElement.parse());
        });
    }
}
